function add(time1, time2) {
	var data1 = new Date(time1).getTime();
	var data2 = new Date(time2).getTime();
	var flag = Number(data1) - Number(data2);
	return flag;
}

//function getNowFormatDate() {
//	var date = new Date();
//	var seperator1 = "-";
//	var seperator2 = ":";
//	var month = date.getMonth() + 1;
//	var strDate = date.getDate();
//	if (month >= 1 && month <= 9) {
//		month = "0" + month;
//	}
//	if (strDate >= 0 && strDate <= 9) {
//		strDate = "0" + strDate;
//	}
//	var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
//	return currentdate;
//}
//
//var startTime = getNowFormatDate();
//			
////			console.log(add("2017-02-23","2017-02-23")); 
//
//			var t = "2012-1-1";
//			var arr = t.split("-");
//			console.log(t.split("-").slice(1));
//			var str = arr.join("")
//			console.log(str)
//			
function p(s) {
	s = Number(s);
	return s < 10 ? '0' + s : s;
}

function addZero(str) {
	var arr = str.split("-");
	for (var i = 0; i < arr.length; i++) {
		arr[i] = p(arr[i]);
	}
	return arr.join("-");
}
//			for (var i = 0; i < arr.length; i++) {
//				arr[i] = p(arr[i]);
//			}
//			console.log(arr.join("-"));
var dayseconds = add("2017-02-24", "2017-02-23");
console.log(dayseconds);

function count(time1, time2) {
	var data1 = new Date(time1).getTime();
	var data2 = new Date(time2).getTime();
	var data3 = data2;
	var counts = [];
	while (data3 >= data1) {
		data3 -= dayseconds;
		var day = new Date(data3);
		counts.push(day.getFullYear() + "-" + (day.getMonth() + 1) + "-" + (day.getDate() + 1));
	}
	return counts.reverse();
}

function compeleteData(data) {
	for (var i = 0; i < data.data.length; i++) {
		data.data[i]["date"] = addZero(data.data[i]["date"]);
		if (i < (data.data.length - 1) && add(data.data[i + 1]["date"], data.data[i]["date"]) > dayseconds) {
			var arr = count(data.data[i]["date"], data.data[i + 1]["date"]);
			for (var j = 1; j < arr.length - 1; j++) {
				arr[j] = addZero(arr[j]);
				var obj = {
					"total": 0
				};
				obj["date"] = arr[j];
				data.data.splice(i + 1, 0, obj);
				i++;
			}
		}
	}
	return data;
}